package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class TravelCommend extends BaseDomain {

    public static final int TYPE_WEEK = 0;

    public static final int TYPE_MONTH = 1;

    public static final int TYPE_STRATEGY = 2;

    private Travel travel; // 推荐对应的游记

    private String title; // 主标题

    private String subTitle; // 副标题

    private String coverUrl; // 背景墙

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date schedule; // 日期

    private Integer type; // 推荐的类型

    public String getJsonString(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",getId());
        map.put("travelId",travel.getId());
        map.put("subTitle",subTitle);
        map.put("title",title);
        map.put("coverUrl",coverUrl);
        map.put("schedule", DateUtil.date2string(schedule,"yyyy-MM-dd"));
        map.put("type",type);
        return JSONUtil.toJSONString(map);
    }

    public String getTypeDisplay(){
        if(type == null){
            return "";
        }
        if(type == TYPE_WEEK){
            return "周推荐";
        } else if(type == TYPE_MONTH){
            return "月推荐";
        }else if(type == TYPE_STRATEGY){
            return "攻略推荐";
        }
        return "";
    }
}